#pragma once

#include <unordered_map>
#include "../share/user_define.h"
#include "../../3rd/libjson/json.h"

/*
"id": 1,
"hp": 0.04,
"physical_attack": 0.6,
"magic_attack": 0.3,
"armor": 2,
"magic_resist": 2,
"physical_critical": 1.25,
"dodge": 1,
"hit_ratio": 1,
"armor_penetration": 4,
"magic_penetration": 4,
"suck_blood": 0.6,
"spell_vamp": 0.6,
"tenacity": 1.25,
"skill": 2
*/

struct FightingCapacity
{
	uint32_t mId;
	double mHp;
	double mPhysicalAttack;
	double mMagicAttack;
	double mArmor;
	double mMagicResist;
	double mPhysicalCritical;
	double mDodge;
	double mHitRatio;
	double mArmorPenetration;
	double mMagicPenetration;
	double mSuckBlood;
	double mSpellVamp;
	double mTenacity;
	double mSkill;

	FightingCapacity()
	{
		Clear();
	}

	void Clear(void)
	{
		mId = 0;
	}
};

class FightingCapacityCacheData
{
public:

	static void CreateInstance(void);
	static FightingCapacityCacheData* GetInstance(void);

	~FightingCapacityCacheData(void);

public:

	bool Initialization(void);

	bool Reload(void);

	FightingCapacity* GetData(uint32_t id);

	bool GetDataJsonString(uint32_t id, Json::Value& _jm);

	uint32_t GetDataCount(void);

private:
	FightingCapacityCacheData(void);

	void Clear(void);

	void AddData(uint32_t id, Json::Value& jm);


private:

	static FightingCapacityCacheData* mInstance;

	std::unordered_map<uint32_t, FightingCapacity*> m_mapCacheData;
	uint32_t m_maxCount;

};